class Solution(object):
    def maxArea(self, height):
        """
        :type height: List[int]
        :rtype: int
        """
        list_len = len(height)
        left_p = 0
        right_p = list_len - 1
        max_area = 0
        while left_p < right_p:
            left_h = height[left_p]
            right_h = height[right_p]
            if left_h > right_h:
                tmp_area = right_h * (right_p - left_p)
                if tmp_area > max_area:
                    max_area = tmp_area
                while left_p < right_p:
                    right_p -= 1
                    if height[right_p] > right_h:
                        break
            else:
                tmp_area = left_h * (right_p - left_p)
                if tmp_area > max_area:
                    max_area = tmp_area
                while left_p < right_p:
                    left_p += 1
                    if height[left_p] > left_h:
                        break
        return max_area

s = Solution()
h = [1,8,6,2,5,4,8,3,7]
result = s.maxArea(h)
print(result)

h = [1,1]
result = s.maxArea(h)
print(result)

h = [1]
result = s.maxArea(h)
print(result)

h = []
result = s.maxArea(h)
print(result)
